package originala;


import javax.swing.JFrame;
import javax.swing.BorderFactory;
import java.awt.Dimension;

import java.awt.Toolkit;
import sun.util.resources.CalendarData_es_ES;

import java.awt.Container;
import java.awt.BorderLayout;
import java.awt.Point;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

class AplikazioNagusia extends JFrame
{
    /**
    * Aplikazio nagusiaren hasierako klasea
    * ======================================
    */
    private ErreserbaSistema LoturaErreserbaSistema;
    public AplikazioNagusia(String izenburuBat)
    {
        // Eraikitzaileen edukiontzia
    	initialize();
        Container contentPane = super.getContentPane();
        setTitle(izenburuBat);
        setSize(700, 600);
        setDefaultCloseOperation(3);
        //Ereduak sortu
        try {
			LoturaErreserbaSistema = new ErreserbaSistema();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NotBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        //Bistak sortu
        ErreserbaBistarenLaburpena erreserbarenBistaSummary = new ErreserbaBistarenLaburpena(LoturaErreserbaSistema);
        OrdaintzaileItenarenBista ordaintzaileItenarenBista = new OrdaintzaileItenarenBista(LoturaErreserbaSistema);
        ErreserbarenBista erreserbarenBista = new ErreserbarenBista(LoturaErreserbaSistema);
        ErreserbaKontroladorea erreserbaKontroladorea  = new ErreserbaKontroladorea(LoturaErreserbaSistema,this);
        //Border erako osagaiak sortu
        erreserbaKontroladorea.setBorder(
            BorderFactory.createTitledBorder("Erreserba Eskaerak"));
        erreserbarenBistaSummary.setBorder(
            BorderFactory.createTitledBorder("Erreserbaren Laburpena"));
        ordaintzaileItenarenBista.setBorder(
            BorderFactory.createTitledBorder("Azken ordaintzailearen laburpena"));
        erreserbarenBista.setBorder(BorderFactory.createTitledBorder("Erreserba"));
        //
        // Eraiki bista
        contentPane.setLayout(new BorderLayout());
        contentPane.add(erreserbarenBistaSummary, BorderLayout.NORTH);
        contentPane.add(erreserbaKontroladorea, BorderLayout.CENTER);
        contentPane.add(erreserbarenBista, BorderLayout.EAST);
        contentPane.add(ordaintzaileItenarenBista, BorderLayout.SOUTH);
        
        this.setVisible(true);
    }
    /**
	 * This method initializes this
	 * 
	 */
	private void initialize() {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        this.setLocation(screenWidth / 4, screenHeight / 8);
			
	}
	public static void main(String[] args)
    {
        new AplikazioNagusia("Erreserba Sistema");
         System.setProperty("java.security.policy","client.policy");
    }
}
